package org.spdata.tsdb.coder;

import java.util.ArrayList;
import java.util.List;

/**
 * 用于把数字序列输出成字符串
 * @author DELL
 *
 */
public class NumberSeqFormatter {
	public static String toString(int[] input) {
		StringBuffer sb = new StringBuffer();
		for(int i=0;i<input.length;i++) {
			sb.append(input[i]).append(" ");
			if(i%40==39) {
				sb.append("\r\n");
			}
		}
		return sb.toString();
	}
	
	public static String toString(float[] input) {
		StringBuffer sb = new StringBuffer();
		for(int i=0;i<input.length;i++) {
			sb.append(input[i]).append(" ");
			if(i%10==9) {
				sb.append("\r\n");
			}
		}
		return sb.toString();
	}
	
	public static float[] toArray(List<Float> input) {
		float[] arr = new float[input.size()];
		int i = 0;
		for(Float f :input) {
			arr[i] =  f;
			i++;
		}
		return arr;
	}
	
	public static List<Number> toList(float[] input) {
		List<Number> list = new ArrayList<Number>();
		for(int i=0;i<input.length;i++ ) {
			list.add(input[i]);
		}
		return list;
	}
	
	public static List<Number> toList(int[] input){
		List<Number> list = new ArrayList<Number>();
		for(int i=0;i<input.length;i++ ) {
			list.add(input[i]);
		}
		return list;
	}
}
